import { sendMessage } from '@/api/mp/message'
import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 报表汇总信息 */
export interface ReportView {
  id: number // id
  name?: string // 名称
  url: string // 链接
  parentId?: number // 父id
  sort?: number // 显示顺序
}

// 报表汇总 API
export const ReportViewApi = {
  // 查询报表汇总分页
  getReportViewPage: async (params: any) => {
    return await request.get({ url: `/business/report-view/page`, params })
  },

  getReportViewList: async (params: any) => {
    return await request.get({ url: `/business/report-view/list`, params })
  },

  // 查询报表汇总详情
  getReportView: async (id: number) => {
    return await request.get({ url: `/business/report-view/get?id=` + id })
  },

  // 消息推送测试
  senComdMessage: async (id: number) => {
    return await request.get({ url: `/business/report-view/sendMessage?id=` + id })
  },

  // 新增报表汇总
  createReportView: async (data: ReportView) => {
    return await request.post({ url: `/business/report-view/create`, data })
  },

  // 修改报表汇总
  updateReportView: async (data) => {
    return await request.put({ url: `/business/report-view/update`, data })
  },

  // 删除报表汇总
  deleteReportView: async (id: number) => {
    return await request.delete({ url: `/business/report-view/delete?id=` + id })
  },

  /** 批量删除报表汇总 */
  deleteReportViewList: async (ids: number[]) => {
    return await request.delete({ url: `/business/report-view/delete-list?ids=${ids.join(',')}` })
  },

  // 导出报表汇总 Excel
  exportReportView: async (params) => {
    return await request.download({ url: `/business/report-view/export-excel`, params })
  },

  // 查询部门（精简)列表
  getSimpleReportList: async () => {
    return request.get({ url: '/business/report-view/simple-list' })
  },

  reportTree: async (params?: any) => {
    return await request.get({ url: '/business/report-view/tree', params })
  }
}
